package flc.ast.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.SelPicShowBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class SelPicShowAdapter extends StkProviderMultiAdapter<SelPicShowBean> {

    public SelPicShowAdapter() {
        addItemProvider(new StkSingleSpanProvider(66));
        addItemProvider(new SelPicShowProvider());
    }

    private class SelPicShowProvider extends BaseItemProvider<SelPicShowBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_sel_pic_show;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, SelPicShowBean bean) {
            if (TextUtils.isEmpty(bean.getPath())) {
                baseViewHolder.getView(R.id.ivSelPicShowItemImg).setVisibility(View.GONE);
                baseViewHolder.getView(R.id.ivSelPicShowItemCha).setVisibility(View.GONE);
            } else {
                baseViewHolder.getView(R.id.ivSelPicShowItemImg).setVisibility(View.VISIBLE);
                baseViewHolder.getView(R.id.ivSelPicShowItemCha).setVisibility(View.VISIBLE);
                Glide.with(getContext()).load(bean.getPath())
                        .into((ImageView) baseViewHolder.getView(R.id.ivSelPicShowItemImg));
            }
//            if (bean.isSelect()) {
//                baseViewHolder.setBackgroundResource(R.id.llSelPicShowItemSel, R.drawable.shape_sel_on);
//            } else {
//                baseViewHolder.getView(R.id.llSelPicShowItemSel).setBackground(null);
//            }
//            if (baseViewHolder.getPosition() == 0 && TextUtils.isEmpty(bean.getPath())) {
//                baseViewHolder.setBackgroundResource(R.id.llSelPicShowItemSel, R.drawable.shape_sel_off);
//            }
        }
    }

}
